﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace MyRoguelike.Tools
{
    class DrawPrimitives
    {
        static private Texture2D _texture;

        /// <summary>
        /// Initialization
        /// </summary>
        /// <param name="spriteBatch">SpriteBatch</param>
        static public void Initialization(Microsoft.Xna.Framework.Game game)
        {
            // Create texture
            _texture = new Texture2D(game.GraphicsDevice, 1, 1);
            _texture.SetData(new Color[] {Color.White});
        }

        /// <summary>
        /// Draw a line
        /// </summary>
        /// <param name="spriteBatch">SpriteBatch</param>
        /// <param name="p1">Start point</param>
        /// <param name="p2">End point</param>
        /// <param name="color">The draw color</param>
        static public void DrawLine(SpriteBatch spriteBatch, Vector2 p1, Vector2 p2, Color color)
        {
            float length = (p2 - p1).Length();
            float rot = (float) Math.Atan2(p2.Y - p1.Y, p2.X - p1.X);
            spriteBatch.Draw(_texture, p1, null, color, rot, Vector2.Zero, new Vector2(length, 1), SpriteEffects.None,
                             0);
        }

        /// <summary>
        /// Draw a fill rectangle
        /// </summary>
        /// <param name="spriteBatch">SpriteBatch</param>
        /// <param name="rectangle">Rectangle</param>
        /// <param name="color">The fill color</param>
        static public void FillRectangle(SpriteBatch spriteBatch, Rectangle rectangle, Color color)
        {
            spriteBatch.Draw(_texture, rectangle, color);
        }

    }
}
